package com.estate.framework.web.pojo;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.HashMap;
import java.util.Map;

@Data
@EqualsAndHashCode(callSuper = false)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ContactFilter {
    private String email;
    private String mobile;
    private String type;
    private String updatedDateFrom;
    private String updatedDateTo;

    public Map<String, String> toMap() {
        Map<String, String> filters = new HashMap<>();
        if (email != null && !email.isEmpty()) {
            filters.put("email", email);
        }
        if (mobile != null && !mobile.isEmpty()) {
            filters.put("mobile", mobile);
        }
        if (type != null && !type.isEmpty()) {
            filters.put("type", type);
        }
        if (updatedDateFrom != null && !updatedDateFrom.isEmpty()) {
            filters.put("updated_date_from", updatedDateFrom);
        }
        if (updatedDateTo != null && !updatedDateTo.isEmpty()) {
            filters.put("updated_date_to", updatedDateTo);
        }
        return filters;
    }
}
